<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j"
	template="/WEB-INF/templates/default.xhtml">
	<ui:define name="menu">
		<ui:include src="/protected/user/menu.xhtml" >
			<ui:param name="activeMenu" value="direccion" />
			<ui:param name="activeSubMenu" value="localidad" />
		</ui:include>		
	</ui:define>	
	<ui:define name="breadcrumb">
		<ui:include src="breadcrumbIndex.xhtml" />
	</ui:define>
	<ui:define name="content">	
		<h:form id="form-search" styleClass="well form-horizontal">
	    	<div class="control-group">
	    		<h:outputLabel value="#{messages.localidadPais}:"  
   					for="paisLocalidad" 
   					styleClass="search-label"/>
				<h:selectOneMenu id="paisLocalidad" 
		    		converter="#{paisBean.converter}"
		    		value="#{localidadBean.pais}">
		    		<f:selectItem itemLabel="#{messages.ingresarValor}" 
		    			noSelectionOption="true"/>
		    		<f:selectItems value="#{paisBean.allEntities}"
		    			var="var" 
		    			itemLabel="#{var.name}" />
		    		<f:ajax event="change"
		    			execute="@this" 
		    			render="form-search:provinciaLocalidad" />
		    	</h:selectOneMenu>	    			
			</div>
	    	<div class="control-group">
	    		<h:outputLabel value="#{messages.localidadProvincia}:"  
   					for="provinciaLocalidad" 
   					styleClass="search-label"/>
				<h:selectOneMenu id="provinciaLocalidad" 
		    		converter="#{provinciaBean.converter}"
		    		value="#{localidadBean.searchFilter.provincia}">
		    		<f:selectItem itemLabel="#{messages.ingresarValor}" 
		    			noSelectionOption="true"/>
		    		<f:selectItems value="#{localidadBean.provincias}"
		    			var="var" 
		    			itemLabel="#{var.name}" />
		    		<f:ajax event="change"
		    			execute="@this" />
		    	</h:selectOneMenu>	    			
			</div>

	    	<div class="control-group">
	    		<h:outputLabel value="#{messages.localidadNombre}:"  
   					for="nombreLocalidad" 
   					styleClass="search-label"/>
				<div class="input-append">
					<h:inputText id="nombreLocalidad" 
						style="margin-left:5px;"
						value="#{localidadBean.searchFilter.nombre}"
						styleClass="input-large search-query">
			    		<f:ajax event="change"
			    			execute="@this" />
					</h:inputText>
					<h:commandLink action="#{localidadBean.search}"
						styleClass="btn btn-primary" >
						<i class="icon-search" title="#{messages.search}"></i>	
						<h:outputText value=" #{messages.search}" />
					</h:commandLink>
				</div>
			</div>
		</h:form>
	
		<h:form id="form-content">
			<rich:dataTable value="#{localidadBean.dataModel}"
				styleClass="table table-bordered table-striped table-condensed"
				keepSaved="true" id="resultTable" var="result" rows="20">
				
				<h:column>
					<f:facet name="header">
						<h:outputText value="#{messages.localidadPais}" />
					</f:facet>
					<h:outputText value="#{result.provincia.pais.name}" />
				</h:column>
	
				<h:column>
					<f:facet name="header">
						<h:outputText value="#{messages.localidadProvincia}" />
					</f:facet>
					<h:outputText value="#{result.provincia.name}" />
				</h:column>
	
				<h:column>
					<f:facet name="header">
						<h:outputText value="#{messages.localidadNombre}" />
					</f:facet>

					<h:commandLink value="#{result.name}"
						action="#{localidadBean.showRead}" immediate="true">
						<f:setPropertyActionListener target="#{localidadBean.entity}" 
							value="#{result}" />
						<f:setPropertyActionListener target="#{localidadBean.persistReturnView}" 
							value="#{facesContext.viewRoot.viewId}"  />
						<f:setPropertyActionListener target="#{localidadBean.cancelView}" 
							value="#{facesContext.viewRoot.viewId}"  />
					</h:commandLink>
				</h:column>
	
	            <h:column>
					<f:facet name="header">
						<h:outputText value="#{messages.actiones}" />
					</f:facet>
					<h:commandLink action="#{localidadBean.showUpdate}"
						immediate="true">
						<i class="icon-edit" title="#{messages.edit}"></i>
						<f:setPropertyActionListener target="#{localidadBean.entity}" 
							value="#{result}" />
						<f:setPropertyActionListener target="#{localidadBean.persistReturnView}" 
							value="#{facesContext.viewRoot.viewId}"  />
						<f:setPropertyActionListener target="#{localidadBean.cancelView}" 
							value="#{facesContext.viewRoot.viewId}"  />
					</h:commandLink>
					<h:commandLink action="#{localidadBean.showDelete}"
						immediate="true">
						<i class="icon-remove" title="#{messages.remove}"></i>
						<f:setPropertyActionListener target="#{localidadBean.entity}" 
							value="#{result}" />
						<f:setPropertyActionListener target="#{localidadBean.persistReturnView}" 
							value="#{facesContext.viewRoot.viewId}"  />
						<f:setPropertyActionListener target="#{localidadBean.cancelView}" 
							value="#{facesContext.viewRoot.viewId}"  />
					</h:commandLink>
	            </h:column>			
	
				<f:facet name="footer">
					<rich:dataScroller id="scroller" renderIfSinglePage="false"
						stepControls="show"
						fastControls="hide"
						styleClass="pagination"
						for="resultTable" maxPages="10">
					</rich:dataScroller>
				</f:facet>								
			</rich:dataTable>
		
			<div class="form-actions">
				<h:commandLink action="#{localidadBean.exportToExcel}"
					styleClass="btn btn-primary"
					immediate="true">
					<i class="icon-download-alt" title="#{messages.exportToExcel}"></i>				
					<h:outputText value=" #{messages.exportToExcel}" />
				</h:commandLink>
				
				<h:commandLink action="#{localidadBean.showCreate}"
					style="margin-left:5px;"
					styleClass="btn btn-info"
					immediate="true">
					<i class="icon-file" title="#{messages.localidadCreate}"></i>				
					<h:outputText value=" #{messages.localidadCreate}" />
				</h:commandLink>
			</div>		
		</h:form>		
	</ui:define>
</ui:composition>